package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelContentItemDto;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author wei
 * @since 2022/09/20 20:30
 */
@RestController
@RequestMapping("/shopping")
public class ProductController {
    @Autowired
    IHomeService iHomeService;

    @GetMapping("/homepage")
    public ResponseData getHomePage() {
        Set<PanelDto> homepage = iHomeService.homepage();
        return new ResponseUtil<>().setData(homepage);
    }

    @GetMapping("/navigation")
    public ResponseData getNavigation(){
        List<PanelContentDto> navigation=iHomeService.navigation();
        return new ResponseUtil<>().setData(navigation);
    }

    @GetMapping("/categories")
    public ResponseData getCategories(){
        List<ProductCateDto> productCateDtos=iHomeService.categories();
        return new ResponseUtil<>().setData(productCateDtos);
    }

}

